package com.sydsen.imager.painter;

import com.sydsen.imager.Canvas;
import com.sydsen.imager.elements.Shape;

import java.awt.*;

/**
 * @Auther: syh
 * @Date: 2021/11/5
 * @Description:
 */
public class ShapePainter extends AbstractPainter<Shape>{
    @Override
    protected void doDraw(Canvas canvas, Shape element) throws Exception {
        canvas.getGraphics().setColor(element.color());
        canvas.getGraphics()
                .setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        canvas.getGraphics()
                .fillRoundRect(element.x(), element.y(), element.width(), element.height(), element.radius(), element.radius());

    }
}
